<%@page import="sdfi.lee.DAO.QuestionDAO"%>
<%@page import="sdfi.lee.Entity.Question"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="<c:url value='/css/showqu.css' />" rel="stylesheet">
<link href="<c:url value='/css/common.css' />" rel="stylesheet">
<script type="text/javascript" src="<c:url value='/js/jquery-1.6.js' />"> </script>
<script type="text/javascript">
	$(function(){
		$(".qshow span").click(function(){
			var text=$(this).text();
			if(text=="显示答案")
				{
					$("div.acontain").hide().siblings(".qshow").children("span").text("显示答案");
					$(this).text("隐藏答案").parent().next().show();
				}
			else
				{
					$(this).text("显示答案").parent().next().hide();
					
				}
		}).click();
		$(".ashow a").click(function(){
			var thisa=$(this);
			var opt={
					data:{qid:thisa.attr("qid"),aid:thisa.attr("aid")},
					url:"../setqAnswer.html",
					dataType:"text",
					success:function(data,status){
						if(data=="success") window.location.reload();
					},
					error:function(status,xhr){
						alert(status);
					}
			};
			$.ajax(opt);
			return false;
		});
		
	});
</script>
<title>查看所有问题</title>
</head>
<body>
	<%
		String pg=request.getParameter("pg");
		String type=request.getParameter("type");
		if(pg!=null&&type!=null){
			List<Question> list=new QuestionDAO().getAllUserQuest(
					2,
					Integer.valueOf(pg).intValue(),
					Integer.valueOf(type).intValue());
			request.setAttribute("list",list);
		}
		
			
		
	%>
	<c:forEach items="${requestScope.list}" var="question">
		<div class="qcontain">
			<div class="qshow">
				问题：${question.question}<span>隐藏答案</span>
			</div>
			<div class="acontain">
				<c:forEach items="${question.qanswers}" var="answer" varStatus="status">
					<div class="ashow">
						<font>${status.index+1}、</font>${answer.answer} <br>
						<a href="" qid="${question.id}" aid="${answer.id}">设为答案入库</a>
					</div>
				</c:forEach>
			</div>
		
		</div>
	</c:forEach>
	<div id="pages">
			<!-- 上一页 -->
			<c:url value="/admin/showqu.jsp?pg=${param.pg-1}&type=${param.type}" var="up"></c:url>
			<!-- 下一页-->
			<c:url value="/admin/showqu.jsp?pg=${param.pg+1}&type=${param.type}" var="down"></c:url>
			<font>
					<c:choose>
						<c:when test="${param.pg==1}">&lt;</c:when>
						<c:otherwise><a href="${up}">&lt;</a></c:otherwise>
					</c:choose>
			</font>
			<font>
				 ${param.pg}
			</font>
			<font>
				<c:choose>
					<c:when test="${fn:length(requestScope.list)<2}">
						&gt;
					</c:when>
					<c:otherwise>
				<a href="${down}">&gt;</a>
					</c:otherwise>
				</c:choose>
			</font>
	</div>
</body>
</html>